package com.dly.blog.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dly.blog.controller.BaseController;
import lombok.AllArgsConstructor;
import com.dly.blog.domain.vo.column.ColumnVO;
import com.dly.blog.domain.ro.column.ColumnPageRO;
import com.dly.blog.domain.ro.column.ColumnAddRO;
import com.dly.blog.domain.ro.column.ColumnEditRO;
import com.dly.blog.service.ColumnService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.dly.blog.domain.vo.PageVO;
import com.dly.blog.msg.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
/**
 * <p>
 * 专栏 前端控制器
 * </p>
 *
 * @author DLY
 * @since 2024-01-24 09:53:18
 */
@Tag(name = "专栏相关")
@AllArgsConstructor
@RestController
@RequestMapping("/content/column")
public class ColumnController extends BaseController {

    private final ColumnService columnService;

    @PostMapping(value = "/page")
    @Operation(summary = "分页获取专栏信息")
    public ResponseEntity<R<PageVO<ColumnVO>>> getColumnPage(@RequestBody ColumnPageRO columnPageRO){
        return operate(()-> this.successDate(columnService.getColumnPage(columnPageRO)));
    }

    @PostMapping(value = "/add")
    @Operation(summary = "添加专栏信息")
    public ResponseEntity<R<Void>> addColumn(@RequestBody ColumnAddRO columnAddRO){
        columnService.addColumn(columnAddRO);
        return operate(this::success);
    }

    @PostMapping(value = "/edit")
    @Operation(summary = "修改专栏信息")
    public ResponseEntity<R<Void>> editColumn(@RequestBody ColumnEditRO columnEditRO){
        columnService.editColumn(columnEditRO);
        return operate(this::success);
    }

    @PostMapping(value = "/get/{id}")
    @Operation(summary = "获取专栏信息")
    public ResponseEntity<R<ColumnVO>> getColumn(@PathVariable(value = "id") String id){
        return operate(()-> this.successDate(columnService.getColumn(id)));
    }

    @PostMapping(value = "/remove/{ids}")
    @Operation(summary = "删除专栏信息")
    public ResponseEntity<R<Void>> removeColumn(@PathVariable(value = "ids") String[] ids){
        columnService.removeColumn(ids);
        return operate(this::success);
    }

}
